package ru.osu.acm.testing.beans;

import javax.faces.context.FacesContext;
import java.util.Locale;

/**
 * User: Aleksey
 * Date: 25.01.2009
 * Time: 3:13:35
 */
public class ChangeLocaleBean {
    private Locale loc = Locale.ENGLISH;

    public String getLocale() {
        return loc.getLanguage();
    }

    public void setLocale(String locale) {
        loc = new Locale(locale);
    }

    public String englishAction() {
        FacesContext context = FacesContext.getCurrentInstance();
        loc = Locale.ENGLISH;
        context.getViewRoot().setLocale(loc);
        return null;
    }

    public String russianAction() {
        FacesContext context = FacesContext.getCurrentInstance();
        loc = new Locale("ru");
        context.getViewRoot().setLocale(loc);
        return null;
    }
}
